package com.example.goods_service.dao;

import com.example.goods_service.vo.T_commodity;
import com.example.goods_service.vo.T_commodity_allocation;
import com.example.goods_service.vo.T_commodity_category;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface Goods_liyongjie {

    @Insert("insert into `t_commodity_category`(category_name,category_parent_ID) values(#{name},#{category_parent_ID})")
    int insertcat(T_commodity_category category);

    @Update("update `t_commodity_category` set category_name=#{name} where id=#{id}")
    int updatecat(T_commodity_category category);

    @Delete("delete from `t_commodity_category` where id=#{id} ")
    int deletecat(T_commodity_category category);

    @Delete("delete from `t_commodity_category` where category_parent_ID=#{id} ")
    int deletecatpid(T_commodity_category category);

    @Select("select * from t_commodity")
    List<T_commodity> selectcom();

    @Update("update t_commodity set status =#{status} where id=#{id}")
    int updacom(T_commodity commodity);

    @Delete("delete from t_commodity where id=#{id}")
    int deletecom(T_commodity commodity);

    @Delete("delete from T_commodity_allocation where commodity_id=#{id}")
    int deletecompz(int category_id);

    @Delete("delete from T_commodity_allocation where commodity_id=${commodity_id} and attribute=${attribute}")
    int deletecompzgg(T_commodity_allocation allocation);

    @Delete("delete from t_category_config where category_id = #{category_id}")
    void deleteconfig(int category_id);

    @Delete("delete from t_category_attribute where category_id = #{category_id}")
    void deleteattribute(int category_id);
}
